import Vue from 'vue'
import VueRouter from 'vue-router'
import Layout from '@/layout'
Vue.use(VueRouter)

import panel from './modules/panel'
import workorder from './modules/workorder'
import point from './modules/point'
import run from './modules/run'
export const  constantRoutes = [
  {
    path:'/',
    component:Layout,
    redirect:'/panel',
    children:[
      {
        path:'',
        component:() => import('@/views/panel'),
      }
    ]
},
{
  path:'/addpop',
  component:Layout,
  hidden: true,
  children:[
      {
          path:'',
          component: () => import('@/views/run/components/addpop'),
       
      }
  ]
},
{
path:'/login',
component:() => import('@/views/login')
}
]
  

// 动态路由
const asyncRouter =
[
 panel ,
 point,
 workorder,
 run,
]
const createRouter = () => new VueRouter({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  // 静态路由动态路由
  routes: [...constantRoutes, ...asyncRouter]
})

const router = createRouter()

export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router